/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.registration.gui.security;

import it.polimi.registration.business.security.boundary.UserManager;
import it.polimi.registration.business.security.entity.User;
import java.io.Serializable;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;



/**
 *
 * @author Stefano
 */
@Named
@RequestScoped
public class ResearchBean implements Serializable {
    
    @EJB
    UserManager um;
    

    
    private User user; 
    private User searchedUser;

    public ResearchBean(){
    }
    
    public User getUser() {
        if (user == null) {
            user = new User();
        }
        return user;
    }
    
    public void setUser(User user) {
        this.user = user;
    }
    
    public User research(){
        searchedUser = um.search(user);
        System.out.println("Ho trovato:" + searchedUser.getName());
        return searchedUser;
    }
    
    public User getSearchedUser(){
        if (searchedUser == null) {
            searchedUser = new User();
        }
        return searchedUser;
    }
    
    public void setSearchedUser(User user) {
        this.searchedUser = user;
    }
    
    
    
}
